<core:set title='Products'/>
<core:WRAP file="page.html" as="content">

<active_record:fetch using='src/model/Product' find='for_front' target="products" navigator='pager'/>

<p/>
<fetch using="src/fetcher/AlphabetFetcher" target="alphabet" />

<route_url params='controller:product'>Display all</route_url>

<list:LIST id="alphabet">
  <list:ITEM>
    <core:OPTIONAL for='current'>
    <b>{$letter|uppercase}</b>
    </core:OPTIONAL>
    <core:DEFAULT for='current'>
    <a href='product?letter={$letter}'>{$letter|uppercase}</a>
    </core:DEFAULT>
  </list:ITEM>
</list:LIST>

<p/><b>Search the products:</b>
<form method="GET" id='search_form' runat='server' action='product'>

  <label for='product'>Product title:</label>
  <input type="text" name="product" id="product" size='10'/>

  <label for='price_greater'>Price greater:</label>
  <input type="text" name="price_greater" id="price_greater" type="text" size='4'/>

  <label for='price_less'>Price less:</label>
  <input type="text" name="price_less" id="price_less" type="text" size='4'/>

  <input type='submit' name='search' value="Search!" class='button'/><br/>
  <input type='hidden' name='action' value='search' runat='client'/>
</form>

<core:include file='pager.html'/>

<list:list id="products">
<table cellpadding="0" cellspacing="0" class='list'>
  <thead>
  </thead>
  <list:item>
  <tr>
   <td>
      <dl>
        <dt>
          <b>{$title}</b><br />
          Price:<b>${$price|number:2, '.'}</b><br/>
          <route_url params='controller:cart,action:add,id:{$id}'>Add to cart</route_url><br/>
         </dt>
         <dd>
            <img src='{$image_path}' class='img'/>
            {$description|nl2br|raw}
         </dd>
      </dl>
    </td>
  </tr>
  </list:item>
</table>
</list:list>

</core:wrap>
